#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

import os

def def2map(file:str)->map:
    if not os.path.exists(file):
        print(f"{file} is invalid.")
        return None
    with open(file,'r') as f:
        ret = {}
        lines = f.readlines()
        for line in lines:
            tokens = line.split()
            if not tokens[0] == '#define':
                continue
            if len(tokens) < 3:
                continue
            ret[tokens[1]] = tokens[2].strip('\"')
    return ret